<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Language" content="zh-CN"><link href="stylesheet.css" media="all" rel="stylesheet" type="text/css">
<title>删除</title>
<script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?d286c55b63a3c54a1e43d10d4c203e75"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script>
</head><body class="SECT1">
<div>
<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><th colspan="5" align="center" valign="bottom">PostgreSQL 8.2.3 中文文档</th></tr>
<tr><td width="10%" align="left" valign="top"><a href="tutorial-update.html" accesskey="P">后退</a></td><td width="10%" align="left" valign="top"><a href="tutorial-sql.html">快退</a></td><td width="60%" align="center" valign="bottom">章2. SQL 语言</td><td width="10%" align="right" valign="top"><a href="tutorial-sql.html">快进</a></td><td width="10%" align="right" valign="top"><a href="tutorial-advanced.html" accesskey="N">前进</a></td></tr>
</table>
<hr align="LEFT" width="100%"></div>
<div class="SECT1"><h1 class="SECT1"><a name="TUTORIAL-DELETE">2.9. 删除</a></h1><a name="AEN909"></a>
<p>数据行可以用 <tt class="COMMAND">DELETE</tt> 命令从表中删除。假设你对 Hayward 的天气不再感兴趣，那么你可以用下面的命令把那些行从表中删除：</p>
<pre class="PROGRAMLISTING">DELETE FROM weather WHERE city = 'Hayward';</pre>
<p>所有属于 Hayward 的天气记录都将被删除。</p>
<pre class="PROGRAMLISTING">SELECT * FROM weather;</pre>
<pre class="SCREEN">     city      | temp_lo | temp_hi | prcp |    date
---------------+---------+---------+------+------------
 San Francisco |      46 |      50 | 0.25 | 1994-11-27
 San Francisco |      41 |      55 |    0 | 1994-11-29
(2 rows)</pre>
<p>使用下面形式的语句时一定要小心：</p>
<pre class="SYNOPSIS">DELETE FROM <tt class="REPLACEABLE"><i>tablename</i></tt>;</pre>
<p>如果没有指定条件，<tt class="COMMAND">DELETE</tt> 将从指定表中删除<span class="emphasis"><i class="EMPHASIS">所有</i></span>行。做这些之前系统不会请求你确认！</p>
</div>
<div>
<hr align="LEFT" width="100%">
<table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td width="33%" align="left" valign="top"><a href="tutorial-update.html" accesskey="P">后退</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">首页</a></td><td width="33%" align="right" valign="top"><a href="tutorial-advanced.html" accesskey="N">前进</a></td></tr>
<tr><td width="33%" align="left" valign="top">更新</td><td width="34%" align="center" valign="top"><a href="tutorial-sql.html" accesskey="U">上一级</a></td><td width="33%" align="right" valign="top">高级特性</td></tr>
</table>
</div>
</body></html>